<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="http://127.0.0.1:3000/api/user/addUser" method="post">
        Name: <input type="text" name="name"> <br>
        age: <input type="text" name="age"> <br>
        money: <input type="text" name="money"> <br>
        password: <input type="text" name="password"> <br>
        <input type="submit" value="Submit">
    </form>
    <br>
    <div>
        <div onclick="refresh()" id="aaa">验证码占位区</div>
    </div>
    <div onclick="refresh()">点击刷新</div>
</body>
<script>
    window.onload = function () {
        refresh()
    }
    async function getData() {
        // let response = await fetch('http://127.0.0.1:3000/getCodeImg');
        // response.json().then(res => {
        //     document.querySelector('#codeImg').innerHTML = res.data; //渲染验证码图片
        // })
    }
    // 刷新方法
    function refresh() {
        // 发送请求
        this.axios.get("http://127.0.0.1:3000/api/captcha").then((res) => {
            console.log(res)
            let svg = res.data.img
            let str = res.data.str
            svg = `<div>${svg}</div>`
            aaa.innerHTML = svg
        })
    }
</script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</html>